// Config variables

$circle-size: 50px;
$loading-ring-thickness: 5px;

// Animations
@keyframes file-download-rotater {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

// Styling
.message-media {

    .in-view-indicator {
        position: absolute;
        width: 100%;
        height: 100%;
    }

    // up/downloading circle element
    .circle {
        display: flex;
        position: relative;
        outline: none;
        border-radius: $circle-size / 2;
        background-color: #808080;
        background-size: cover;
        width: $circle-size;
        min-width: $circle-size;
        height: $circle-size;
        min-height: $circle-size;

        // centering element
        &.center {
            margin: 0 auto;
        }

        i,
        img {
            position: relative;
            margin: auto;
            border-radius: $material-radius;
            background: rgba(128, 128, 128, .3);
            color: #ffffff;
        }
    }

    // Loading indicator
    .loading.active {
        display: block;
        position: absolute;
        top: 0;
        left: 0;
        animation: file-download-rotater 1.1s infinite linear;
        border: $loading-ring-thickness solid rgba(0, 0, 0, .1);
        border-radius: 50%;
        border-left-color: #90ee90;
        width: $circle-size - (2 * $loading-ring-thickness);
        height: $circle-size - (2 * $loading-ring-thickness);
    }

    .animgif {
        img {
            max-width: 100%;
            max-height: 100%;
        }
    }

    // Thumbnails
    .thumbnail {
        position: relative;
        max-width: 350px;
        max-height: 350px;
        overflow: hidden;

        &.large-preview {
            min-width: 160px;
            min-height: 100px;
        }

        &.clickable {
            cursor: pointer;
        }

        .preview-image {
            max-width: 100%;
            max-height: 100%;
        }

        // Styling of loader
        .loading-wrapper {
            display: none;
            position: absolute;
            background-color: rgba(0, 0, 0, .2);
            width: 100%;
            height: 100%;

            &.active {
                display: block;
                z-index: 10;
            }

            .loading {
                display: block;
                position: absolute;
                top: calc(50% - #{$circle-size / 2} - 1em);
                left: calc(50% - #{$circle-size / 2});
                animation: file-download-rotater 1.1s infinite linear;
                border: $loading-ring-thickness solid rgba(255, 255, 255, .3);
                border-radius: 50%;
                border-left-color: #90ee90;
                width: $circle-size - (2 * $loading-ring-thickness);
                height: $circle-size - (2 * $loading-ring-thickness);
            }

            .loading-text {
                display: block;
                position: absolute;
                top: calc(50% + #{$circle-size/2});
                width: 100%;
                height: 1em;
                text-align: center;
                color: #ffffff;
            }
        }

        .overlay {
            &.video,
            &.gif {
                position: absolute;
                width: 100%;
                height: 100%;

                i {
                    position: absolute;
                    top: calc(50% - #{$circle-size / 2});
                    left: calc(50% - #{$circle-size / 2});
                    border-radius: $circle-size - (2 * $loading-ring-thickness);
                    background: rgba(128, 128, 128, .6);
                    line-height: $circle-size;
                    font-size: $circle-size;
                }
            }
        }
    }

    // File messages (Files, Audio, ...)
    .file-message {
        height: $circle-size;

        &.clickable {
            cursor: pointer;
        }

        .message-text {
            padding-top: 8px;
        }

        .info {
            position: relative;
            top: -$circle-size;
            margin-left: $circle-size + 16px;
            height: $circle-size;
            line-height: $circle-size;

            p {
                margin: 0;
                padding: 0;
                overflow: hidden;
                text-overflow: ellipsis;
                line-height: normal;
                font-size: 10pt;

                &:first-child {
                    font-size: 100%;
                }
            }
        }

    }
}
